# -*- coding: utf-8 -*-
"""
Created on Thu Dec 03 13:22:46 2015

@author: liliangrong
"""
def test(url):
    import urllib       #sohu 手机主页
    #url = "http://m.sohu.com/?v=3&_once_=000025_v2tov3&_smuid=ICvXXapq5EfTpQTVq6Tpz"
    resp = urllib.urlopen(url)
    page = resp.read()
    f = open("./urllib_index.html", "w")
    f.write(page)
    print dir(resp)
    print resp.getcode()
    print resp.geturl()
    #print resp.info()
    print resp.headers
    print resp.url


if __name__ == "__main__":
    import time
    start = time.clock()
    url = "http://m.sohu.com/?v=3&_once_=000025_v2tov3&_smuid=ICvXXapq5EfTpQTVq6Tpz"
    
    import urllib
    urllib.urlretrieve(url,"./test.html")
    
    test(url)
    end = time.clock()
    print "run time %f s" %(end-start)